package com.zjl.cms.service;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zjl.cms.dao.BaseDao;
import com.zjl.cms.model.Posts;

@Service
public class PostService {
	@Autowired
	private BaseDao baseDao;

	public Map<Long, Posts> findMultileMapByIds(List ids) {
		Map<String, Posts> rets = new HashMap<String, Posts>();
		if (ids == null || ids.isEmpty()) {
			return Collections.emptyMap();
		}

		rets = baseDao.findByIds(ids);

		HashSet<Long> uids = new HashSet<>();

		list.forEach(po -> {
			rets.put(po.getId(), BeanMapUtils.copy(po, 0));
			uids.add(po.getAuthorId());
		});

		// 加载相册
		buildAttachs(rets.values(), ids);

		// 加载用户信息
		buildUsers(rets.values(), uids);

		return rets;
	}
}
